//
//  NewsDetail.m
//  Ghac 4S
//
//  Created by apple on 11-11-9.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "NewsDetail.h"

@implementation NewsDetail
@synthesize textView;
@synthesize titleLabel;
@synthesize imageView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)dealloc
{
    [self viewDidUnload];
    [super dealloc];
}
-(NSString *)title
{
    return titleLabel.text;
}
-(void)setTitle:(NSString *)title
{
    [titleLabel setText:title];
}
-(void)setImage:(NSString *)imagePath
{
    CGRect textFrame;
    if (imagePath == Nil)
    {
        [self.imageView setHidden:YES];
        CGRect imageFrame = self.imageView.frame;
        textFrame = CGRectMake(imageFrame.origin.x, imageFrame.origin.y, imageFrame.size.width, imageFrame.size.height + 190);
        [self.textView setFrame:textFrame];
    }
    else
    {
        NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]];
        UIImage* image = [UIImage imageWithData:data];
        [self.imageView setImage:image];
        [self.imageView setHidden:NO];
        CGRect imageFrame = self.imageView.frame;
        textFrame = CGRectMake(imageFrame.origin.x, imageFrame.origin.y + imageFrame.size.height, imageFrame.size.width, 190);
        [self.textView setFrame:textFrame];
    }
    
}
- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    self.textView = nil;
    self.titleLabel = nil;
    self.imageView = nil;
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
